home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / utils / st_type.lzh / st_type.c next >
C/C++ Source or Header  |  1991-02-13  |  5KB  |  181 lines

  1. /*    ST_TYPE.C
  2. *    Program to find details of the ST similar to HiSoft's CHECKST.PRG
  3. *
  4. *    Thanks to HiSoft for the idea and their excellent service to the 
  5. *    ST community and for Lattice C v5
  6. *
  7. *    Mark S Baines
  8. *    v1.3
  9. *    20 10 90
  10. *    Lattice C v5.06.01
  11. *
  12. *    NB: many functions are necessarily Lattice v5 ones and so this code will
  13. *    probably not compile on another compiler without work. Also I've no idea
  14. *    whether this will work on ALL ST varieties, it should though :->
  15. */
  16.  
  17.  
  18. #include <aes.h>
  19. #include <vdi.h>
  20. #include <dos.h>
  21. #include <osbind.h>
  22. #include <stdlib.h>
  23. #include <stdio.h>
  24.  
  25. static char *country;                    /* global variables */
  26. static char *memory;
  27. static char *rez;
  28. static char *rom_date;
  29. static char *device = "CON:";            /* for printing to the console */
  30.  
  31. int gdos;
  32. long phystop_value, sysbase_value;
  33. short blitter, rom_ver, aes_ver; 
  34. unsigned short dos_ver;
  35.  
  36.  
  37. char *which_country(int value)            /* return country of ROM string */
  38. {
  39.     switch(value)
  40.     {
  41.         case 0: country = "USA"; break;
  42.         case 1: country = "Germany"; break;
  43.         case 2: country = "France"; break;
  44.         case 3: country = "Great Britain"; break;
  45.         case 4: country = "Spain"; break;
  46.         case 5: country = "Italy"; break;
  47.         case 6: country = "Sweden"; break;
  48.         case 7: country = "Switzerland (French)"; break;
  49.         case 8: country = "Switzerland (German)"; break;
  50.         case 9: country = "Turkey"; break;
  51.         case 10: country = "Finland"; break;
  52.         case 11: country = "Norway"; break;
  53.         case 12: country = "Denmark"; break;
  54.         case 13: country = "Saudi Arabia"; break;    /* 13 and 14 may be */
  55.         case 14: country = "Holland"; break;        /* transposed */
  56.         default: country = "Unknown"; break;
  57.     }
  58.     return (country);
  59. }    
  60.  
  61.  
  62. long sysbase(void)                        /* find contents of ST variable '_sysbase' */
  63. {
  64.     long m = *(long*) 0x4F2;
  65.     return m;
  66. }
  67.  
  68.  
  69. char *peek_date(char *rom_date)            /* peek ROM for ROM date */
  70. {
  71.     rom_date[0] = *(char*) (sysbase_value + 0x18);
  72.     rom_date[1] = *(char*) (sysbase_value + 0x19);
  73.     rom_date[2] = *(char*) (sysbase_value + 0x1A);
  74.     rom_date[3] = *(char*) (sysbase_value + 0x1B);
  75.     return rom_date;
  76. }
  77.  
  78.  
  79. long phystop(void)                        /* find contents of ST variable 'phystop' */
  80. {
  81.     long m = *(long*) 0x42E;
  82.     return m;
  83. }
  84.  
  85.  
  86. char *which_mem(long value)                /* return amount of memory string */
  87. {
  88.     switch(value)
  89.     {
  90.         case 0x40000: memory = "256 K"; break;
  91.         case 0x80000: memory = "512 K"; break;
  92.         case 0x100000: memory = "1 Mb"; break;
  93.         case 0x180000: memory = "1.5 Mb"; break;
  94.         case 0x200000: memory = "2 Mb"; break;
  95.         case 0x280000: memory = "2.5 Mb"; break;
  96.         case 0x300000: memory = "3 Mb"; break;
  97.         case 0x380000: memory = "3.5 Mb"; break;
  98.         case 0x400000: memory = "4 Mb"; break;
  99.         default: memory = "Unknown"; break;
  100.     }
  101.     return (memory);
  102. }
  103.  
  104.  
  105. char *which_res(short value)            /* return the resolution string */
  106. {
  107.     switch(value)
  108.     {
  109.         case 0: rez = "Low Colour Resolution"; break;
  110.         case 1: rez = "Medium Colour Resolution"; break;
  111.         case 2: rez = "Mono - High Resolution"; break;
  112.         default: rez = "Unknown - A3 Monitor, Atari TT??"; break;
  113.     }
  114.     return (rez);
  115. }
  116.  
  117.  
  118. void results(void)                        /* get results */
  119. {
  120.     appl_init();                        /* for AES version number */
  121.     dos_ver = Sversion();                /* GEMDOS version */
  122.     rez = which_res(Getrez());            /* monitor resolution */
  123.     blitter = Blitmode(-1);                /* blitter present */
  124.     gdos = vq_gdos();                    /* GDOS present */
  125.     aes_ver = _AESglobal[0];            /* AES version */
  126.     country = which_country(_country);    /* country of ROM */
  127.     rom_ver = _tos;                        /* TOS version */
  128.     phystop_value = Supexec(phystop);    /* get end of physical memory under Supervisor mode */
  129.     memory = which_mem(phystop_value);    /* amount of RAM memory */
  130.     sysbase_value = Supexec(sysbase);    /* get ROM start address under Supervisor mode */
  131.     rom_date = Supexec(peek_date);        /* ROM creation date under Supervisor mode */
  132.     appl_exit();
  133. }
  134.  
  135.  
  136. void printout(void)                        /* printout results */
  137. {
  138.     FILE *fp;
  139.  
  140.     fp = fopen(device,"w");                /* open file device for writing */
  141.     fprintf(fp,"ST TYPE v1.3\n");        /* print results to device */
  142.     fprintf(fp,"by Mark S Baines 1990\n\n");
  143.     fprintf(fp,"TOS Version:    %d.%d\n\n",rom_ver>>8,rom_ver&0xff);
  144.     fprintf(fp,"ROM Date:       %x %x %x%x\n\n",rom_date[1],rom_date[0],rom_date[2],rom_date[3]);
  145.     fprintf(fp,"GEMDOS Version: %d.%d\n\n",dos_ver&0xff,dos_ver>>8);
  146.     fprintf(fp,"AES Version:    %d.%x\n\n",aes_ver>>8,aes_ver&0xff);
  147.     fprintf(fp,"Nationality:    %s\n\n",country);
  148.     fprintf(fp,"Monitor:        %s\n\n",rez);
  149.     fprintf(fp,"RAM Memory:     %s\n\n",memory);
  150.     if (blitter&2)
  151.         fprintf(fp,"Blitter Chip:   Yes\n\n");
  152.     else
  153.         fprintf(fp,"Blitter Chip:   No\n\n");
  154.     if (gdos == 0)
  155.         fprintf(fp,"GDOS Loaded:    No\n\n");
  156.     else
  157.         fprintf(fp,"GDOS Loaded:    Yes\n\n");
  158.     fclose(fp);                            /* close file device */
  159. }
  160.  
  161.  
  162. void main(void)                            /* get and display results */
  163. {
  164.     int c;
  165.  
  166.     results();                            /* get results */
  167.     printout();                            /* print to console */
  168.     printf("\a\nPress \033pp\033q to send to Printer\n");
  169.     printf("Press Return to exit\n");
  170.     
  171.     c = getch();
  172.     if (c == 'p' || c == 'P')
  173.     {
  174.         device = "PRN:";                /* print to printer if user requires */
  175.         printout();
  176.         exit(EXIT_SUCCESS);        
  177.     }
  178.     else                                /* or exit */
  179.         exit(EXIT_SUCCESS);
  180. }
  181.